package com.ruoyi.cms.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 秦耀东请
 * @version 1.0
 * @description: TODO
 * @date 2024/7/20 14:42
 */
@RestController
@RequestMapping("/live")
@CrossOrigin
public class LiveController extends BaseController {

    @PostMapping("/login")
    public AjaxResult login(String username,String password){
        if(!password.equals("123")){
            return AjaxResult.error();
        }

        String txSecret="";
        String txTime="";

        long time = System.currentTimeMillis() / 1000 + 3600;
        txTime=Long.toHexString(time).toUpperCase();

        String param="84f48ca5c77581cffbe36287d9b96909"+username+txTime;
        txSecret = DigestUtils.md5Hex(param);


        Map map = new HashMap<>();
        map.put("txTime",txTime);
        map.put("txSecret",txSecret);

        return AjaxResult.success(map);
    }
}
